﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using JEng_Mark_1.Interfaces;
using Microsoft.Xna.Framework.Graphics;

namespace JEng_Mark_1.Shaders
{
    public class JBasicEffect : IJEngShader
    {
        #region IJEngShader Members

        private BasicEffect _baseEffect;
        /// <summary>
        /// Gets the underlying effect
        /// </summary>
        public Effect BaseEffect
        {
            get { return _baseEffect; }
        }

        private bool _readyToRender = false;
        /// <summary>
        /// Is the shader loaded and initialzed?
        /// </summary>
        public bool ReadyToRender
        {
            get { return _readyToRender; }
        }

        /// <summary>
        /// Initializes the Effect from byte code for the given graphics device
        /// </summary>
        /// <param name="graphicsDevice">Graphics device</param>
        public void Initialize(GraphicsDevice graphicsDevice)
        {
            Initialize(graphicsDevice, CompilerOptions.None, null);
        }

        /// <summary>
        /// Initializes the Effect from byte code for the given GraphicsDevice and CompilerOptions
        /// </summary>
        /// <param name="graphicsDevice">Device to use</param>
        /// <param name="compilerOptions">Options to use</param>
        public void Initialize(GraphicsDevice graphicsDevice, CompilerOptions compilerOptions)
        {
            Initialize(graphicsDevice, compilerOptions, null);
        }

        /// <summary>
        /// Initializes the Effect from byte code for the give GraphicsDevice,CompilerOptions, and EffectPool
        /// </summary>
        /// <param name="graphiceDevice">Device to use</param>
        /// <param name="compilerOptions">Options to use</param>
        /// <param name="effectPool">EffectPool to use</param>
        public void Initialize(GraphicsDevice graphiceDevice, CompilerOptions compilerOptions, EffectPool effectPool)
        {
            _baseEffect = new BasicEffect(graphiceDevice, effectPool);
            _readyToRender = true;
        }
        #endregion
    }
}
